import 'package:flutter/material.dart';

class HeroAnimationWidget extends StatelessWidget {
  const HeroAnimationWidget({
    super.key,
    required this.tag,
    required this.child,
  });
  final String tag;
  final Widget child;
  @override
  Widget build(BuildContext context) {
    return Hero(
      tag: tag,
      child: child,
      flightShuttleBuilder: (
        BuildContext flightContext,
        Animation<double> animation,
        HeroFlightDirection flightDirection,
        BuildContext fromHeroContext,
        BuildContext toHeroContext,
      ) {
        return ColoredBox(
          color: Colors.deepOrange,
          child: FadeTransition(
            opacity: Tween(begin: 0.1, end: 1.0).animate(CurvedAnimation(
                parent: animation, curve: Curves.fastOutSlowIn)),
            child: toHeroContext.widget,
          ),
        );
      },
    );
  }
}
